const Router = require("@koa/router");
const router = new Router();
const {
  updatePkg,
  addPkg,
  deletePkg,
  queryAllData,
  queryAppTrain
} = require('../controller/train')

router.post("/get", async (ctx) => {
  ctx.body = await queryAllData(ctx.request.body)
});
// 增
router.post("/add", async (ctx) => {
  ctx.body = await addPkg(ctx.request.body)
});
// 改
router.post("/:id", async (ctx, next) => {
  ctx.body = await updatePkg(ctx.request.body, ctx.params.id)
});
// 删除
router.delete("/:id", async (ctx, next) => {
  ctx.body = await deletePkg(ctx.params.id)
});
router.post("/app/get", async (ctx) => {
  ctx.body = await queryAppTrain(ctx.request.body)
});
module.exports = router;
